<template>
  <div class="app-container">
    <el-form
      :model="formInline"
      :inline="true"
      ref="ruleForm"
    >
      <el-form-item label="三方平台" prop="channelId">
        <el-select
          v-model="formInline.channelId"
          placeholder="请选择渠道类型"
          filterable
        >
          <el-option
            v-for="item in channelList"
            :label="item.channelName"
            :value="item.channelId"
            :key="item.channelId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="商户号" prop="merchantCode">
        <el-input
          v-model="formInline.merchantCode"
          placeholder="请输入商户号码"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="渠道类型" prop="limitType">
        <el-select
          v-model="formInline.limitType"
          placeholder="请选择支付类型"
        >
          <el-option
            v-for="item in payEnum.PAY_TYPE"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          >
            {{item.title}}
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="开关状态" prop="status">
        <el-select
          v-model="formInline.status"
          placeholder="请选择开关状态"
        >
          <el-option
            v-for="item in payEnum.PAY_STATUS_TYPE"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          >
            {{item.title}}
          </el-option>
        </el-select>
      </el-form-item>
      <el-button
        class="filter-item"
        type="primary"
        icon="el-icon-search"
        @click="onClickSearch"
        :loading="$parent.loading"
      >
        搜索
      </el-button>
      <el-button
        @click="onClickResetForm('ruleForm')"
      >
        重置
      </el-button>
    </el-form>
  </div>
</template>


<script>

// constants
import { paySetType } from '@/router/payRoutes';

import { getPaymentManageChannelList } from '@/services/api/recharge';

// mixins
import { grid } from '@/build';

export default {
  name: 'receipt',
  mixins: [grid],
  data() {
    return {
      paySetType,
      formInline: {
        limitType: -1,
        merchantCode: null,
        channelId: -1,
        status: -1,
      },
      channelList: [],
    };
  },
  methods: {
    onClickSearch() {
      this.$emit('on-filter', this.formInline);
    },
    onClickResetForm(formName) {
      this.resetForm(formName);
      this.onClickSearch();
    },
  },
  mounted() {
    this.bindGet(getPaymentManageChannelList, 'channelList', {
      format: (data) => {
        data.unshift({ channelId: -1, channelName: '全部' });
        return data;
      },
    });
    this.getAll();
  },
};
</script>

<style lang="scss" scoped>
  .el-table-align-center {
    &.el-table {
      width: 100%;
      text-align: center !important;
      th {
        text-align: center !important;
      }
    }
  }

</style>
